<template>
	<view class="mainpadding2">
		<view class="flexcenter" v-if="!list.data.length">
			<view class="placeholderimage" style="margin-top: 300rpx;" ></view>
		</view>
		<view class="xiahuaxian margin_top" v-for="item in list.data" :key="item.id" @click="tzkecxq(item.id)">
			<view class="flexbetween">
				<view class="shilitu">
					<image :src="item.image_text" mode=""></image>
				</view>
				<view class="" style="width: 69%;">
					<view class="titletext xiaohei fonweight yhxk">{{item.name}} </view>
					<view class="flexleft margin_top2">
						<view class="smalltext xiaohui nofonweight margin_right2">{{item.userzbfapply.name}}
						</view>
						<view class="line margin_right2"></view>
						<view class="smalltext xiaohui nofonweight yhxk">{{item.cityinfo}}
						</view>
					</view>
					<view class="flexbetween margin_top2">
						<view class="sanshier xiaohong fonweight">¥ {{item.priceinfo.price}}</view>
						</view>
					</view>
				</view>
		</view>
	</view>
</template>
<script>
	const httpRequest = require("@/common/httpRequest.js")
	export default {
		data() {
			return {
				page: 1,
				limit: 12,
				list: {
					data: []
				},
				type:1,//1教练课程，2场馆课程
				listid:""
			}
		},
		onLoad(options) {
			this.type = options.type
			this.listid = options.id
			this.init()
		},
		methods: {
			// 跳转课程详情
			tzkecxq(id) {
				uni.navigateTo({
					url: '/pages_homepage/kechenggmxq?id=' + id
				})
			},
			init(isPage, page) {
				let _this = this;
				let data = {
					page: page || 1,
					limit: _this.limit,
					jl_user_zbfapply_id: this.listid
				}
				let url = '/api/kccl/kcIndex'
				if(this.type==2){
					delete data.jl_user_zbfapply_id
					this.$set(data,"user_zbfapply_id",this.listid)
				}
				httpRequest.request(url, 'GET', data, false, false, true).then(res => {
					if (res.code == 1) {
						let resList = res.data;
						let dataList = _this.list;
						if (isPage == true) {
							_this.list.data = dataList.data.concat(resList.data);
						} else {
							this.list = res.data
							_this.list.data = resList.data;
						}
					}
				})
			},
			onReachBottom() {
				let _this = this;
				let list = _this.list;
				let page = _this.page;
				if (list.last_page <= page) {
					return false;
				}
				page++;
				_this.page = page;
				_this.init(true, page);
			},
		}
	}
</script>

<style lang="scss" scoped>
	.xiaolvbtn {
		width: 112rpx;
		height: 56rpx;
		background: #1BA95B;
		border-radius: 32rpx 32rpx 32rpx 32rpx;
		font-size: 26rpx;
		font-family: PingFang SC-Regular, PingFang SC;
		font-weight: 400;
		color: #FFFFFF;
		display: flex;
		align-items: center;
		justify-content: center;
	}

	.line {
		width: 2rpx;
		height: 24rpx;
		background: #EEEEEE;
	}

	.shilitu {
		width: 200rpx;
		height: 160rpx;

		image {
			width: 100%;
			height: 100%;
		}
	}
</style>